package com.zbkj.crmeb.store.controller;

import javax.servlet.http.HttpServletRequest;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.crmeb.core.exception.CrmebException;
import com.github.pagehelper.PageInfo;
import com.zbkj.crmeb.merchant.admin.controller.AdminBaseController;
import com.zbkj.crmeb.merchant.api.controller.ApiBaseController;
import com.zbkj.crmeb.store.request.ExhibitApplicationSearchRequest;
import com.zbkj.crmeb.store.response.ExhibitApplicationResponse;
import com.zbkj.crmeb.store.service.ExhibitApplicationService;

/**
 * 展会报名表 前端控制器
 *
 */
@RestController
@RequestMapping("api/store/exhibit/application")
public class AdminExhibitApplicationController extends AdminBaseController {
    @Autowired
    private ExhibitApplicationService exhibitApplicationService;

    /**
     * 分页显示展会报名表
     *
     * @param request          搜索条件
     * @param pageParamRequest 分页参数
     */
    @ApiOperation(value = "展会报名分页列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<ExhibitApplicationResponse>> getRecordList(@Validated ExhibitApplicationSearchRequest request, @Validated PageParamRequest pageParamRequest, HttpServletRequest servletRequest) {
        request.setMerId(getMerId(servletRequest));
        if(request.getMerId() == null || request.getMerId() == 0){
            throw new CrmebException("获取商户id异常!");
        }
        PageInfo<ExhibitApplicationResponse> pageInfo = exhibitApplicationService.getList(request, pageParamRequest);
        return CommonResult.success(CommonPage.restPage(pageInfo));
    }

}
